﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CustomControls
{
    public partial class FormNotifyIcon : Form
    {
        int  soLuongNhap, soLuongXuat, soLuongTon;
        string textBaloon;
        public FormNotifyIcon()
        {
            InitializeComponent();
        }
        //public FormNotifyIcon(decimal sln,decimal slx,decimal slt)
        public FormNotifyIcon(decimal slt)
        {
            //soLuongNhap = Convert.ToInt32(sln);
            //soLuongXuat = Convert.ToInt32(slx);
            soLuongTon = Convert.ToInt32(slt);
            InitializeComponent();
        }

        private void FormNotifyIcon_Load(object sender, EventArgs e)
        {
            if (DesignMode) return;
            //string textBaloon = string.Format("Số lượng nhâp: {0}, số lượng xuất: {1}, số lượng tồn: {2} ", soLuongNhap, soLuongXuat, soLuongTon); 
            textBaloon = string.Format("Số lượng tồn :{0} ",soLuongTon); 
            timerCheckClose.Start();
            if (WindowState == FormWindowState.Normal)
            {
                ntfThongBao.ShowBalloonTip(0, "Thông báo tồn", textBaloon, ToolTipIcon.Info);             
            }
        }

        private void FormNotifyIcon_Paint(object sender, PaintEventArgs e)
        {
            Hide();
        }

        private void timerCheckClose_Tick(object sender, EventArgs e)
        {
            try
            {
                this.Close();
            }
            catch (Exception ex)
            {
            }
        }

        private void FormNotifyIcon_FormClosed(object sender, FormClosedEventArgs e)
        {
            ntfThongBao.Dispose();
            Dispose();
        }
    }
}
